package cn.yili12.business.mq.handler;

import cn.yili12.business.mq.bean.Message;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

@Component
public class ReadHandler extends BaseHandler {
    @Override
    public boolean handler(Message message) {
        //已读消息是批量操作
        JSONArray jsonArray = JSON.parseArray(message.getData());
        List<String> ids = jsonArray.stream().map(obj -> String.valueOf(obj)).collect(Collectors.toList());
        service.updateRead(ids);
        return true;
    }
}
